package org.example.exception;

import org.example.common.ResponseMessage;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalException {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public ResponseMessage ServiceException(ServiceException e){

        return ResponseMessage.error(e.getCode(),e.getMessage());
    }
}
